// activity_push
exports.activity_push = function(req,res) {

    //获取restful参数
    var restfulParams = req.routeInfo.restfulParams;

    var resultData = {};

    //任务流创建
    async.waterfall([

        //获取活动列表
        function(cb){

            var now = Date.parse(new Date())*0.001;

            R.SEND_HTTP(
                req,
                {
                    url    : CORE_APIConfig.coreAPI.search_organization_activity + "/oa_oid/"+ restfulParams.organization_id + "/between/" + now + "-oa_end_time/limit/20",
                    method : 'POST',
                    data   : {
                        fields : ["oa_id", "oa_title", "oa_start_time", "oa_end_time"].join(",")
                    }
                },
                function (err, data) {

                    resultData.activityData = data.data;

                    cb();
                }
            );

        },
        function (cb) {
            var activityData = resultData.activityData;
            R.SEND_HTTP(
                req,
                {
                    url    : CORE_APIConfig.coreAPI.searchActivityBrowseRecordFixUser+"/count/1/oabr_oaid/"+ activityData[0].oa_id,
                    method : "GET",
                },
                function (err, data) {

                    resultData.browsedCount = data.count;

                    cb();
                }
            );
        },
        function(cb){

            R.SEND_HTTP(
                req,
                {
                    url    : CORE_APIConfig.coreAPI.searchOrganization + "/o_id/"+ restfulParams.organization_id,
                    method : 'POST',
                    data   : {
                        fields : ["o_name"].join(",")
                    }
                },
                function (err, data) {

                    resultData.organizationName = data.data[0].o_name;

                    cb();
                }
            );

        },
    ],function(err, result){

        //返回最终拼接结果
        RES.response(res,true,resultData);

    });
}